#include <stdio.h>

int main(int argc, char *argv[]) {

    int size = 0,insertNum=0;
    scanf("%d", &size);
    size += 1;
    int nums[size+1];
    
    for (size_t i = 0; i < size-1; i++)
    {
        scanf("%d", &nums[i]);
    }

    int tempSize = size;

    scanf("%d", &insertNum);
    
    int index = 0;
    for (size_t i = 0; i < size-1; i++)
    {
        if(nums[i]<=insertNum){
            index = i+1;
        }else{
            break;
        }
    }

    
    for (size_t i = size; i > index; i--)
    {
        nums[size] = nums[size - 1];
        size -= 1;
    }

    nums[index] = insertNum;

    for (size_t i = 0; i < tempSize; i++)
    {
        printf("%d ", nums[i]);
    }

    return 0;
}